/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * <p>Project: javaweb - Hello
 * <p>Powered by webrx On 2022-03-09 11:29:35
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */

@WebServlet(value = "/hello.do",initParams = {@WebInitParam(name="aa",value = "/user/abc")} )
public class Hello extends HttpServlet {

    /**
     * Description: 初始化servlet
     * @date: 2022/3/9 11:31
     * @params: []
     * @return: void
     */
    public void init() throws ServletException {
        System.out.println("public void init()");
    }


    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String m = req.getMethod();
        //重定向
        //resp.sendRedirect("/ok.jsp");
        //转发，派发，可以使用req.setAttribute() 传值
        //req.getRequestDispatcher("ok.jsp").forward(req,resp);
        System.out.println(m);

        System.out.println(this.getInitParameter("aa"));
        System.out.println(this.getInitParameter("username"));
        System.out.println(this.getInitParameter("path"));
        System.out.println(this.getInitParameter("charset"));
    }

    public void destroy() {
        System.out.println("销毁方法:public void destroy()");
    }
}
